<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="portal" uri="http://amc.af.mil/portal-el" %>
<%@ taglib prefix="rad" uri="http://amc.af.mil/radtaglibrary" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
    <title>Create DRMO Package</title>
    <link type="text/css" rel="stylesheet" href="yui/build/calendar/assets/skins/sam/calendar.css"/>
    <link type="text/css" rel="stylesheet" href="yui/build/calendar/assets/skins/sam/calendar-skin.css"/>
    <link type="text/css" rel="stylesheet" href="yui/build/button/assets/skins/sam/button.css"/>
    <script type="text/javascript" src="yui/build/yuiloader/yuiloader-beta-min.js"></script>
    <script type="text/javascript" src="yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="yui/build/calendar/calendar.js"></script>
    <style type="text/css">
        #calContainer {
            display: none;
            position: absolute;
            left: 200px;
            top: 300px;
            z-index: 1
        }
    </style>
</head>

<body>

<rad:useBean id="adpeAccountViewHelper"/>
<rad:useBean id="equipmentTypeViewHelper"/>
<div id="portal-left-bar">
    <jsp:include page="../navigation/navigationMenu.jsp"/>
</div>

<div id="portal-content">
    <portal:box title="Create DRMO Package" style="width:800px">
        <portal:subSection title="Basic Information">
            <div id="createDrmoPackage" class="yui-skin-sam">
                <html:form action="createDrmoPackage.do" method="post">
                    <p>
                        <label for="adpeAccount">ADPE Account</label>
                        <html:select property="adpeAccount" styleId="adpeAccount">
                            <html:optionsCollection name="adpeAccountViewHelper"
                                                    property="adpeAccountsByAccount"
                                                    value="id"
                                                    label="name"/>
                        </html:select>
                    </p>

                    <p><label for="dtid">DTID</label><html:text property="dtid" styleId="dtid"/></p>

                    <p><label for="status">Package Status</label>
                        <html:select property="statusId" styleId="statusId">
                            <html:option value="1">Pending</html:option>
                            <html:option value="2">Complete</html:option>
                        </html:select></p>

                    <p><label for="itemConditionId">Item Condition</label>
                        <html:select property="itemConditionId" styleId="statusId">
                            <html:option value="0">Serviceable (A)</html:option>
                            <html:option value="1">Unserviceable (H)</html:option>
                        </html:select></p>

                    <p>
                        <label for="turninDate">Turnin Date</label>
                        <html:text property="turninDate" styleId="turninDate" readonly="true"/>
                        <button type="button" id="showCalendar">
                            <img src="images/calendar-icon.gif" alt="Calendar"/>
                        </button>

                        <div id="parent1" class="yui-skin-sam">
                            <div id="calContainer"></div>
                        </div>
                    </p>

                    <p><label for="search">Serial</label><html:text property="search" styleId="search"/>
                        <input type="button" value="Search" onclick="javascript:createRosPackageDataRow();"/>

                        <div id="searchStatus">

                        </div>
                    </p>

                    <table style="width:100%" id="itemTable">
                        <tbody id="header">
                            <tr id="itemTableHeader">
                                <th>Serial</th>
                                <th>Description</th>
                                <th>Actions</th>
                            </tr>
                        </tbody>
                        <tbody id="content">

                        </tbody>
                    </table>

                    <p><html:submit title="Create Package"/></p>
                </html:form>
            </div>
        </portal:subSection>

    </portal:box>
</div>
<script type="text/javascript">
    YAHOO.namespace("createPackage.turninDate");
    YAHOO.createPackage.turninDate.init = function() {

        YAHOO.createPackage.turninDate.calendar = new YAHOO.widget.Calendar("tdCalendar",
                "calContainer",
        {close: true, title: 'Purchase Date'});

        YAHOO.createPackage.turninDate.calendar.render();
        YAHOO.createPackage.turninDate.calendar.hide();

        YAHOO.util.Event.addListener('showCalendar', 'click', showCalendar);

        YAHOO.createPackage.turninDate.calendar.selectEvent.subscribe(handleSelect,
                YAHOO.createPackage.turninDate.calendar,
                true);
    }

    function showCalendar() {
        YAHOO.createPackage.turninDate.calendar.show();

    }

    function handleSelect(type, args, obj) {

        var allDates = args[0];
        var singleDate = allDates[0];

        var months = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];

        var year = singleDate[0];
        var month = singleDate[1] - 1;
        var day = singleDate[2];

        var formattedDate = day + '-' + months[month] + '-' + year;

        document.getElementById('turninDate').value = formattedDate;

        YAHOO.createPackage.turninDate.calendar.hide();
    }

    YAHOO.util.Event.onDOMReady(YAHOO.createPackage.turninDate.init);
</script>
</body>


</html>